﻿using Db4objects.Db4o;
using Db4objects.Db4o.Config;
using Db4objects.Db4o.Query;

namespace HoldemGame
{

    public class Database
    {
        private static Database _instance;
        private static IObjectContainer _container;

        public static Database Instance
        {
            get
            {
                return _instance;
            }
        }

        public IObjectContainer DB
        {
            get{
                return _container;
            }
        }

        public Database(IObjectContainer container)
        {
            _container = container;
            _instance = this;
        }

        public static IConfiguration DBConfig
        {
            get {
                IConfiguration cfg = Db4oFactory.NewConfiguration();
                return cfg;
            }
        }

        public static Database OpenFile(string file)
        {
            IObjectContainer cont = Db4oFactory.OpenFile(DBConfig, file);
            Database db = new Database(cont);
            return db;
        }
    }
}